home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CDsupport / aMiPEG / source / chunky2planar.s < prev    next >
Text File  |  1996-06-26  |  10KB  |  627 lines

  1. ;
  2. ; This source handles the conversion from 24-bit data to HAM8, initialization
  3. ; of the screen and so on.
  4. ;
  5. ; Support for Kaiko is not yet build-in, but very easy to accomplish, as it
  6. ; makes flush_cunkyloop completely obsolete. Looking forward to see
  7. ; custom logic like this, possibly more flexible, built-in in all Amigas.
  8. ;
  9. ; Phew! This one consumes 43% of the overall processor time in hires, 33% in
  10. ; lores. I want this Kaiko thingy!
  11. ;
  12. ;
  13. ; Michael Rausch  14-4-94  1:15:00
  14. ;
  15.  
  16.  
  17.     SECTION    text,CODE
  18.  
  19.     include    "graphics/rastport.i"
  20.     include    "graphics/gfx.i"
  21.  
  22.     XREF    _max_x
  23.     XREF    _max_y
  24.  
  25.  
  26.     XDEF    @HAM6_Init_lores
  27. @HAM6_Init_lores:
  28.     movem.l    d2-d7/a2-a6,-(sp)
  29.  
  30. ;         RGBG  BRGB  R=8 G=C B=4
  31. P7    set    %0111
  32. P8    set    %1101
  33.  
  34.     move.l    #(P7<<28)|(P7<<24)|(P7<<20)|(P7<<16)|(P7<<12)|(P7<<8)|(P7<<4)|P7,d5
  35.     move.l    #(P8<<28)|(P8<<24)|(P8<<20)|(P8<<16)|(P8<<12)|(P8<<8)|(P8<<4)|P8,d6
  36.  
  37.     move.l    a0,HAM8_rastport
  38.     move.l    (rp_BitMap,a0),a0
  39.  
  40.     moveq    #0,d1
  41.     move.w    (bm_BytesPerRow,a0),d1
  42.     move.l    d1,HAM8_offset        ; we have advanced one complete line when accessing this
  43.  
  44.     lea    (bm_Planes,a0),a6
  45.     move.l    a6,HAM8_screen
  46.  
  47.     move.l    (a6)+,a1
  48.     move.l    (a6)+,a2
  49.     move.l    (a6)+,a3
  50.     move.l    (a6)+,a4
  51.     move.l    (a6)+,a5
  52.     move.l    (a6),a6
  53.  
  54.     moveq.l    #0,d4
  55.  
  56.     lsr.l    #2,d1            ; longs
  57.     subq.l    #1,d1
  58.  
  59.     move.w    (bm_Rows,a0),d0
  60.     subq.w    #1,d0
  61. h6_prep_rows:
  62.  
  63.     move.l    d1,d2
  64. h6_prep_nulls:
  65.     move.l    d4,(a1)+
  66.     move.l    d4,(a2)+
  67.     move.l    d4,(a3)+
  68.     move.l    d4,(a4)+
  69.  
  70.     move.l    d5,(a5)+
  71.     move.l    d6,(a6)+
  72.  
  73.     dbra    d2,h6_prep_nulls
  74.  
  75.     dbra    d0,h6_prep_rows
  76.  
  77.     movem.l    (sp)+,d2-d7/a2-a6
  78.     rts
  79.  
  80.  
  81.  
  82.     XDEF    @HAM8_Init_lores
  83. @HAM8_Init_lores:
  84.     movem.l    d2-d7/a2,-(sp)
  85.  
  86. ;         RGBG  BRGB  R=8 G=C B=4
  87. P7    set    %0111
  88. P8    set    %1101
  89.  
  90.     move.l    #(P7<<28)|(P7<<24)|(P7<<20)|(P7<<16)|(P7<<12)|(P7<<8)|(P7<<4)|P7,d5
  91.     move.l    #(P8<<28)|(P8<<24)|(P8<<20)|(P8<<16)|(P8<<12)|(P8<<8)|(P8<<4)|P8,d6
  92.     bra.s    ham8cont
  93.  
  94.     XDEF    @HAM8_Init
  95. @HAM8_Init:                ; init from rastport data
  96.     movem.l    d2-d7/a2,-(sp)
  97.  
  98. ;         BRGB  R=8 G=C B=4
  99. P7    set    %1011
  100. P8    set    %0110
  101.  
  102.     move.l    #(P7<<28)|(P7<<24)|(P7<<20)|(P7<<16)|(P7<<12)|(P7<<8)|(P7<<4)|P7,d5
  103.     move.l    #(P8<<28)|(P8<<24)|(P8<<20)|(P8<<16)|(P8<<12)|(P8<<8)|(P8<<4)|P8,d6
  104.  
  105. ham8cont:
  106.     bsr    std_init
  107. prep_rows:
  108.  
  109.     move.l    d1,d2
  110. prep_nulls:
  111.     move.l    d4,(a1)+
  112.     move.l    d4,(a1)+
  113.     move.l    d4,(a1)+
  114.     move.l    d4,(a1)+
  115.     move.l    d4,(a1)+
  116.     move.l    d4,(a1)+
  117.     dbra    d2,prep_nulls
  118.  
  119.     move.l    a1,a0
  120.     add.l    a2,a0
  121.  
  122.     move.l    d1,d2
  123.     lsr.l    #1,d2            ; ohoh
  124. prep_cols67:
  125.     move.l    d5,(a1)+
  126.     move.l    d5,(a1)+
  127.     move.l    d6,(a0)+
  128.     move.l    d6,(a0)+
  129.     dbra    d2,prep_cols67
  130.  
  131.     add.l    a2,a1
  132.     dbra    d0,prep_rows
  133.  
  134.     movem.l    (sp)+,d2-d7/a2
  135.     rts
  136.  
  137.  
  138.  
  139.     XDEF    @HAM8_Init_x3
  140. @HAM8_Init_x3:                ; init from rastport data
  141.     movem.l    d2-d7/a2-a3,-(sp)
  142.  
  143.     bsr.s    std_init
  144. prep_rows_3:
  145.  
  146.     move.l    d1,d2
  147. prep_nulls_3:
  148.     move.l    d4,(a1)+
  149.     move.l    d4,(a1)+
  150.     move.l    d4,(a1)+
  151.     move.l    d4,(a1)+
  152.     move.l    d4,(a1)+
  153.     move.l    d4,(a1)+
  154.     dbra    d2,prep_nulls_3
  155.  
  156.     move.l    a1,a0
  157.     add.l    a2,a0
  158.  
  159.     lea    (scale3tab1,pc),a3
  160.     move.l    d1,d2
  161. prep_cols67_3:
  162.     move.l    (scale3tab2-scale3tab1,a3),(a0)+
  163.     move.l    (a3)+,(a1)+
  164.     subq.w    #1,d2
  165.     bmi.s    pc67_ready_3
  166.     move.l    (scale3tab2-scale3tab1,a3),(a0)+
  167.     move.l    (a3)+,(a1)+
  168.     subq.w    #1,d2
  169.     bmi.s    pc67_ready_3
  170.     move.l    (scale3tab2-scale3tab1,a3),(a0)+
  171.     move.l    (a3)+,(a1)+
  172.     sub.w    #3*4,a3
  173.     dbra    d2,prep_cols67_3
  174. pc67_ready_3:
  175.  
  176.     add.l    a2,a1
  177.     dbra    d0,prep_rows_3
  178.  
  179.     movem.l    (sp)+,d2-d7/a2-a3
  180.     rts
  181.  
  182. ;         BRG    R=8 G=C B=4
  183. P7    set    %101
  184. P8    set    %011
  185.  
  186. scale3tab1:
  187.     dc.l    (P7<<29)|(P7<<26)|(P7<<23)|(P7<<20)|(P7<<17)|(P7<<14)|(P7<<11)|(P7<<8)|(P7<<5)|(P7<<2)|(P7>>1)
  188.     dc.l    (P7<<31)|(P7<<28)|(P7<<25)|(P7<<22)|(P7<<19)|(P7<<16)|(P7<<13)|(P7<<10)|(P7<<7)|(P7<<4)|(P7<<1)|(P7>>2)
  189.     dc.l    (P7<<30)|(P7<<27)|(P7<<24)|(P7<<21)|(P7<<18)|(P7<<15)|(P7<<12)|(P7<<9)|(P7<<6)|(P7<<3)|P7
  190. scale3tab2:
  191.     dc.l    (P8<<29)|(P8<<26)|(P8<<23)|(P8<<20)|(P8<<17)|(P8<<14)|(P8<<11)|(P8<<8)|(P8<<5)|(P8<<2)|(P8>>1)
  192.     dc.l    (P8<<31)|(P8<<28)|(P8<<25)|(P8<<22)|(P8<<19)|(P8<<16)|(P8<<13)|(P8<<10)|(P8<<7)|(P8<<4)|(P8<<1)|(P8>>2)
  193.     dc.l    (P8<<30)|(P8<<27)|(P8<<24)|(P8<<21)|(P8<<18)|(P8<<15)|(P8<<12)|(P8<<9)|(P8<<6)|(P8<<3)|P8
  194.  
  195.  
  196.  
  197. std_init:
  198.     move.l    a0,HAM8_rastport
  199.     move.l    (rp_BitMap,a0),a0
  200.     moveq    #0,d1
  201.     move.w    (bm_BytesPerRow,a0),d1
  202.     move.l    (bm_Planes,a0),a1
  203.     move.l    a1,HAM8_screen
  204.     move.l    (bm_Planes+4,a0),a2
  205.     sub.l    a1,a2            ; plane delta
  206.  
  207.     cmp.l    a2,d1
  208.     bgt.s    check_interleaved
  209.     sub.l    a2,a2            ; RED ALERT, no interlaved bitmap or strange, weirdo layout!
  210. check_interleaved:
  211.     move.l    a2,HAM8_next
  212.     move.l    d1,HAM8_offset        ; we have advanced one complete line when accessing this
  213.  
  214.     moveq.l    #0,d4
  215.  
  216.     move.l    a2,d1
  217.     lsr.l    #2,d1            ; longs
  218.     subq.l    #1,d1
  219.  
  220.     move.w    (bm_Rows,a0),d0
  221.     subq.w    #1,d0
  222.     rts
  223.  
  224. ********************************************************
  225.  
  226.     XDEF    @HAM6_draw_lores    ;     (data=a0, x=d0, y=d1)
  227. @HAM6_draw_lores:
  228.     movem.l    d2-d7/a2-a4,-(sp)
  229.  
  230.     move.l    d0,d7
  231.     asr.l    #4,d0
  232.     and.l    #$0f,d7
  233.     beq.s    h6_skip
  234.     addq.l    #1,d0
  235. h6_skip
  236.     asl.l    #4,d0
  237.  
  238.     move.l    _max_y(a4),d7
  239.     cmp.l    d7,d1
  240.     bge.s    h6_max128lores
  241.     move.l    d1,d7        ; height
  242. h6_max128lores:
  243.     subq.l    #1,d7
  244.  
  245.     move.l    _max_x(a4),d1
  246.     cmp.l    d1,d0
  247.     bge.s    h6_max160lores
  248.     move.l    d0,d1        ; width
  249. h6_max160lores:
  250.  
  251.     move.l    d1,d6
  252.     lsr.w    #4,d6
  253.     subq.w    #1,d6        ; width in 8 pixel chunks
  254.  
  255.     and.w    #$fff0,d1    ; correct eol of over-large pix
  256.     sub.l    d1,d0
  257.  
  258.     move.l    d0,d2        ; this is some quick fix for 360 pixels wide b0.mpg, which is invalid!
  259.     and.w    #8,d2
  260.     add.w    d2,d0
  261.  
  262.     add.l    d0,d0        ; 1 word per pixel
  263.     move.l    d0,line_offset
  264.  
  265.     move.l    HAM8_screen,a1
  266.     addq.l    #4,a1
  267.     move.l    (a1)+,a2
  268.     move.l    (a1)+,a3
  269.     move.l    (a1),a4
  270.     move.l    -12(a1),a1
  271.  
  272.     move.l    HAM8_offset,d2
  273.     move.l    d6,d0
  274.     addq.l    #1,d0
  275.     lsl.l    #2,d0        ; writing one long per main loop
  276.     sub.l    d0,d2
  277.     move.l    d2,draw_offset
  278.  
  279. h6_draw_all_rows_lores:
  280.     move.l    d7,-(sp)
  281.     move.l    d6,d5
  282.  
  283. h6_blocks_loop_lores:
  284.  
  285.     moveq    #7,d4
  286. h6_flush_chunkyloop_lores:
  287.     move.w    (a0)+,d7        ; RGBG
  288.  
  289.     rept    4
  290.     add.w    d7,d7
  291.     addx.l    d0,d0
  292.     add.w    d7,d7
  293.     addx.l    d1,d1
  294.     add.w    d7,d7
  295.     addx.l    d2,d2
  296.     add.w    d7,d7
  297.     addx.l    d3,d3
  298.     endr
  299.  
  300.     dbra    d4,h6_flush_chunkyloop_lores
  301.  
  302.     move.l    d3,(a1)+
  303.     move.l    d2,(a2)+
  304.     move.l    d1,(a3)+
  305.     move.l    d0,(a4)+
  306.  
  307.     dbra    d5,h6_blocks_loop_lores
  308.  
  309.     add.l    line_offset,a0
  310.  
  311. ;    move.l    draw_offset,d1
  312. ;    add.l    d1,a1
  313. ;    add.l    d1,a2
  314. ;    add.l    d1,a3
  315. ;    add.l    d1,a4
  316.  
  317.     move.l    (sp)+,d7
  318.     dbra    d7,h6_draw_all_rows_lores
  319.  
  320.  
  321.     movem.l    (sp)+,d2-d7/a2-a4
  322.     rts
  323.  
  324.  
  325. ********************************************************
  326.  
  327.  
  328.     XDEF    @HAM8_draw_lores    ;     (data=a0, x=d0, y=d1)
  329. @HAM8_draw_lores:
  330.     movem.l    d2-d7/a2-a6,-(sp)
  331.  
  332.     move.l    d0,d7
  333.     asr.l    #4,d0
  334.     and.l    #$0f,d7
  335.     beq.s    h8_skip
  336.     addq.l    #1,d0
  337. h8_skip
  338.     asl.l    #4,d0
  339.  
  340.     move.l    _max_y(a4),d7
  341.     cmp.l    d7,d1
  342.     bge.s    max128lores
  343.     move.l    d1,d7        ; height
  344. max128lores:
  345.     subq.l    #1,d7
  346.  
  347.     move.l    _max_x(a4),d1
  348.     cmp.l    d1,d0
  349.     bge.s    max160lores
  350.     move.l    d0,d1        ; width
  351. max160lores:
  352.  
  353.     move.l    d1,d6
  354.     lsr.w    #4,d6
  355.     subq.w    #1,d6        ; width in 8 pixel chunks
  356.  
  357.     and.w    #$fff0,d1    ; correct eol of over-large pix
  358.     sub.l    d1,d0
  359.  
  360.     move.l    d0,d2        ; this is some quick fix for 360 pixels wide b0.mpg, which is invalid!
  361.     and.w    #8,d2
  362.     add.w    d2,d0
  363.  
  364.     add.l    d0,d0        ; 1 word per pixel
  365.     move.l    d0,line_offset
  366.  
  367.  
  368.     move.l    HAM8_screen,a1    ; get addr, prep next line
  369.     move.l    HAM8_next,d1
  370.     move.l    a1,a2
  371.     add.l    d1,a2
  372.     move.l    a2,a3
  373.     add.l    d1,a3
  374.     move.l    a3,a4
  375.     add.l    d1,a4
  376.     move.l    a4,a5
  377.     add.l    d1,a5
  378.     move.l    a5,a6
  379.     add.l    d1,a6
  380.  
  381.     move.l    HAM8_offset,d2
  382.     move.l    d6,d0
  383.     addq.l    #1,d0
  384.     lsl.l    #2,d0        ; writing one long per main loop
  385.     sub.l    d0,d2
  386.     move.l    d2,draw_offset
  387.  
  388.  
  389. draw_all_rows_lores:
  390.     move.l    d7,-(sp)
  391.     move.l    d6,-(sp)
  392.  
  393. blocks_loop_lores:
  394.     move.l    d6,-(sp)
  395.  
  396.     moveq    #7,d6
  397. flush_chunkyloop_lores:
  398.     move.l    (a0)+,d7        ; RGBG
  399.  
  400.     add.l    d7,d7
  401.     addx.l    d0,d0
  402.     add.l    d7,d7
  403.     addx.l    d1,d1
  404.     add.l    d7,d7
  405.     addx.l    d2,d2
  406.     add.l    d7,d7
  407.     addx.l    d3,d3
  408.     add.l    d7,d7
  409.     addx.l    d4,d4
  410.     add.l    d7,d7
  411.     addx.l    d5,d5
  412.  
  413.     rept    3
  414.     lsl.l    #3,d7
  415.     addx.l    d0,d0
  416.     add.l    d7,d7
  417.     addx.l    d1,d1
  418.     add.l    d7,d7
  419.     addx.l    d2,d2
  420.     add.l    d7,d7
  421.     addx.l    d3,d3
  422.     add.l    d7,d7
  423.     addx.l    d4,d4
  424.     add.l    d7,d7
  425.     addx.l    d5,d5
  426.     endr
  427.  
  428.     dbra    d6,flush_chunkyloop_lores
  429.     
  430.     move.l    d5,(a1)+
  431.     move.l    d4,(a2)+
  432.     move.l    d3,(a3)+
  433.     move.l    d2,(a4)+
  434.     move.l    d1,(a5)+
  435.     move.l    d0,(a6)+
  436.  
  437.     move.l    (sp)+,d6
  438.     dbra    d6,blocks_loop_lores
  439.  
  440.     add.l    line_offset,a0
  441. ;    sub.l    #12,a0
  442.  
  443.     move.l    draw_offset,d1
  444.     add.l    d1,a1
  445.     add.l    d1,a2
  446.     add.l    d1,a3
  447.     add.l    d1,a4
  448.     add.l    d1,a5
  449.     add.l    d1,a6
  450.  
  451.     move.l    (sp)+,d6
  452.     move.l    (sp)+,d7
  453.     dbra    d7,draw_all_rows_lores
  454.  
  455.  
  456.     movem.l    (sp)+,d2-d7/a2-a6
  457.     rts
  458.  
  459.  
  460. ********************************************************
  461.  
  462.  
  463.     XDEF    @HAM8_draw_hires    ; (data=a0, x=d0, y=d1)
  464. @HAM8_draw_hires:
  465.     movem.l    d2-d7/a2-a6,-(sp)
  466.  
  467.     move.l    d0,d7
  468.     asr.l    #4,d0
  469.     and.l    #$0f,d7
  470.     beq.s    h8h_skip
  471.     addq.l    #1,d0
  472. h8h_skip
  473.     asl.l    #4,d0
  474.  
  475.     move.l    _max_y(a4),d7
  476.     cmp.l    d7,d1
  477.     bge.s    max128
  478.     move.l    d1,d7        ; height
  479. max128:    subq.l    #1,d7
  480.  
  481.     move.l    _max_x(a4),d1
  482.     cmp.l    d1,d0
  483.     bge.s    max160
  484.     move.l    d0,d1        ; width
  485. max160:
  486.  
  487.     move.l    d1,d6
  488.     lsr.w    #3,d6
  489.     subq.w    #1,d6        ; width in 8 pixel chunks
  490.  
  491.     and.w    #$fff8,d1    ; correct eol of over-large pix
  492.     sub.l    d1,d0
  493.     lsl.l    #2,d0        ; 1 long per pixel
  494.     move.l    d0,line_offset
  495.  
  496.  
  497.     move.l    HAM8_screen,a1        ; get addr, prep next line
  498.     move.l    HAM8_next,d1
  499.     move.l    a1,a2
  500.     add.l    d1,a2
  501.     move.l    a2,a3
  502.     add.l    d1,a3
  503.     move.l    a3,a4
  504.     add.l    d1,a4
  505.     move.l    a4,a5
  506.     add.l    d1,a5
  507.     move.l    a5,a6
  508.     add.l    d1,a6
  509.  
  510.     move.l    HAM8_offset,d2
  511.     move.l    d6,d0
  512.     addq.l    #1,d0
  513.     lsl.l    #2,d0
  514.     sub.l    d0,d2
  515.     move.l    d2,draw_offset
  516.  
  517. draw_all_rows:
  518.     move.l    d7,-(sp)
  519.     move.l    d6,-(sp)
  520.  
  521. blocks_loop:
  522.     move.l    d6,-(sp)
  523.  
  524.  
  525.     moveq    #7,d6
  526. flush_chunkyloop:
  527.     move.l    (a0)+,d7        ; BRG0
  528.  
  529.     add.l    d7,d7
  530.     addx.l    d0,d0
  531.     add.l    d7,d7
  532.     addx.l    d1,d1
  533.     add.l    d7,d7
  534.     addx.l    d2,d2
  535.     add.l    d7,d7
  536.     addx.l    d3,d3
  537.     add.l    d7,d7
  538.     addx.l    d4,d4
  539.     add.l    d7,d7
  540.     addx.l    d5,d5
  541.  
  542.     rept    2
  543.     lsl.l    #3,d7
  544.     addx.l    d0,d0
  545.     add.l    d7,d7
  546.     addx.l    d1,d1
  547.     add.l    d7,d7
  548.     addx.l    d2,d2
  549.     add.l    d7,d7
  550.     addx.l    d3,d3
  551.     add.l    d7,d7
  552.     addx.l    d4,d4
  553.     add.l    d7,d7
  554.     addx.l    d5,d5
  555.     endr
  556.  
  557.     add.l    d0,d0
  558.     add.l    d1,d1
  559.     add.l    d2,d2
  560.     add.l    d3,d3
  561.     add.l    d4,d4
  562.     add.l    d5,d5
  563.  
  564.     dbra    d6,flush_chunkyloop
  565.  
  566.  
  567.     move.l    #$11111111,d6
  568. copcol    macro    (reg)
  569.     move.l    \1,d7
  570.     lsr.l    #3,d7            ; BRGB
  571.     and.l    d6,d7
  572.     or.l    d7,\1
  573.     endm
  574.     copcol    d0
  575.     copcol    d1
  576.     copcol    d2
  577.     copcol    d3
  578.     copcol    d4
  579.     copcol    d5
  580.     
  581.     move.l    d5,(a1)+
  582.     move.l    d4,(a2)+
  583.     move.l    d3,(a3)+
  584.     move.l    d2,(a4)+
  585.     move.l    d1,(a5)+
  586.     move.l    d0,(a6)+
  587.  
  588.     move.l    (sp)+,d6
  589.     dbra    d6,blocks_loop
  590.  
  591.     add.l    line_offset,a0
  592.  
  593.     move.l    draw_offset,d1
  594.     add.l    d1,a1
  595.     add.l    d1,a2
  596.     add.l    d1,a3
  597.     add.l    d1,a4
  598.     add.l    d1,a5
  599.     add.l    d1,a6
  600.  
  601.     move.l    (sp)+,d6
  602.     move.l    (sp)+,d7
  603.     dbra    d7,draw_all_rows
  604.  
  605.  
  606.     movem.l    (sp)+,d2-d7/a2-a6
  607.     rts
  608.  
  609.  
  610. ********************************************************
  611.  
  612.  
  613.     SECTION    __MERGED,BSS
  614.  
  615.  
  616. HAM8_rastport:    ds.l    1            ; original rastport struct
  617. HAM8_screen:    ds.l    1            ; first bitplane
  618. HAM8_offset:    ds.l    1            ; next line in the first bitplane
  619. HAM8_next:    ds.l    1            ; next bitplane
  620.  
  621. draw_offset:    ds.l    1
  622. line_offset:    ds.l    1
  623.  
  624. is_interleaved: ds.w    1
  625.  
  626.     END
  627.